package model

import "fmt"

type Cart struct {
	CartID      string
	CartItems   []*CartItem //购物车中的所有购物项
	TotalCount  int64
	TotalAmount float64
	UserID      int //当前购物车所属的用户
	UserName    string
}

func (cart *Cart) GetTotalAmount() float64 {
	var totalAmount float64
	for _, v := range cart.CartItems {
		totalAmount += v.GetAmount()
		fmt.Println(totalAmount)
	}
	fmt.Println(totalAmount)
	return totalAmount
}
func (cart *Cart) GetTotalCount() int64 {
	var totalCount int64
	for _, v := range cart.CartItems {
		totalCount += v.Count
	}
	return totalCount
}
